# -*- coding:UTF-8 -*-
from  django.core.urlresolvers import reverse
from django.http import HttpResponse,HttpResponseRedirect
def login_required():
    '''依赖于session'''
    def _auth(func):
        def login(request,*args,**kwargs):
            currentUrl = request.get_full_path()
            if request.session.has_key("username"):
                return func(request,*args,**kwargs)
            return HttpResponseRedirect(reverse("login") + '?next=' + currentUrl)
        return login
    return _auth